//==============================================================================
//
// Title:       USB6501.h
// Purpose:     A short description of the interface.
//
// Created on:  2011-9-16 at 23:46:30 by luh.
// Copyright:   dafda. All Rights Reserved.
//
//==============================================================================

#ifndef __USB6501_H__
#define __USB6501_H__

#ifdef __cplusplus
    extern "C" {
#endif

//==============================================================================
// Include files

#include "cvidef.h"
#include "NIDAQmx.h"
#include "comdef.h"

//==============================================================================
// Constants
/**************************************p1[7-0]************************************/
#define TX1TOFB1LOOP 0xfe   //1111111111111110B 
#define TX2TOFB2LOOP 0xfd   //1111111111111101B 
#define TX3TOFB3LOOP 0xfb   //1111111111111011B
#define TX4TOFB4LOOP 0xf7   //1111111111110111B
/**************************************p0[7-0]************************************/
#define LMPCARDON    0xfe   //1111111111111110B
#define LMPCARDOOFF  0xff   //1111111111111111B
/**************************************p0[7-0]************************************/
#define BSCANSHORTCHAIN 0xfd    //1111111111111101B flash
#define BSCANLONGCHAIN  0xfe    //1111111111111110B  test

//==============================================================================
// Types
typedef struct _tagDAQMXWRITELINESCMD{
char ucTashName[64];
char ucDevportlines[64];
uInt8 uWriteData[8];                            //write to portlines  line0-----line7 ,uWriteData[0]-----uWriteData[0]
}_DAQMX_WRITE_LINES_CMD;


typedef struct _tagDAQMXWRITEONELINECMD{
char ucTashName[64];
char ucDevportline[64];
uInt8 uWriteData;                               
}_DAQMX_WRITE_ONE_LINE_CMD;

typedef struct _tagDAQMXWRITEPORTCMD{
char ucTashName[64];
char ucDevport[64];
uInt32 uiWriteData;
}_DAQMX_WRITE_PORT_CMD;                       //write to port  bit7-----bit0 ,uWriteData  bit7-----bit0

typedef struct _tagDAQMXREADLINESCMD{
char ucTashName[64];
char ucDevportlines[64];
uInt8 uReadData[100];                               
}_DAQMX_READ_LINES_CMD;

typedef struct _tagDAQMXREADONELINECMD{
char ucTashName[64];
char ucDevportline[64];
uInt8 uReadata[100];                               
}_DAQMX_READ_ONE_LINE_CMD;

typedef struct _tagDAQMXREADPORTCMD{
char ucTashName[64];
char ucDevport[64];
uInt32 uiReadata;                               
}_DAQMX_READ_PORT_CMD;

//==============================================================================
// External variables

//==============================================================================
// Global functions
int InitDIO(void);

int USBWriteDigToPort(const char *ptrTashName,const char *ptrDevport, uInt32 vInput);
int USBWriteDigToAllLines(const char *ptrTashName,const char *ptrDevportlines, uInt8 *ptrucDataToLine);
int USBWriteDigToOneLine(const char *ptrTashName,const char *ptrDevportline, uInt8 ucDataToLine);
int USBReadDigFromPort(const char *ptrTashName,const char *ptrDevportline, uInt32 *ptrDataFromLine);
int USBReadDigFromAllLines(const char *ptrTashName,const char *ptrDevportline, uInt8 *ptrDataFromLine);
int USBReadDigFromOneLine(const char *ptrTashName,const char *ptrDevportline, uInt8 *ptrDataFromLine);

#ifdef __cplusplus
    }
#endif

#endif  /* ndef __USB6501_H__ */
